﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.DataVisualization.Charting;

namespace BOMS.WebUI.Web.RealStatus
{
    public partial class groupPageListInfoChart : System.Web.UI.Page
    {
        public string WinceIP
        {
            get { return Request.QueryString["winceIp"]; }
        }
        public string WinceMac
        {
            get { return Request.QueryString["WinceMac"]; }
        }
        public string LanName
        {
            get { return Request.QueryString["lanname"]; }
        }
        public string WinceName
        {
            get { return Request.QueryString["winceName"]; }
        }
        public string GroupID
        {
            get { return Request.QueryString["groupid"]; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            rbl.SelectedIndexChanged += new EventHandler(rbl_SelectedIndexChanged);

            if (!IsPostBack)
            {
                lbIntro.Text = string.Format("" + LanName + "" + WinceName + "现场主机(IP:{0})  电池组:{1} 实时监控数据", WinceIP, GroupID);
                BindChart(rbl.SelectedValue);
                btn_back.PostBackUrl = "groupPageList.aspx?winceIp=" + WinceIP + "&WinceMac=" + WinceMac + "&winceName=" + HttpUtility.UrlEncodeUnicode(WinceName) + "&lanName=" + HttpUtility.UrlEncodeUnicode(LanName) + "";
            }
        }

        void rbl_SelectedIndexChanged(object sender, EventArgs e)
        {
            //绑定图表
            BindChart(rbl.SelectedValue);
        }

        private void BindChart(string YField)
        {
            BLL.S_BatSubLog bll = new BLL.S_BatSubLog();
            List<Model.S_BatSubLog> list = bll.GetRealTimeBatteryData(Common.GENRATION_NUM, WinceMac, GroupID);
            System.Web.Script.Serialization.JavaScriptSerializer jsSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            this.JsonData1.Text = jsSerializer.Serialize(list);
        }
    }
}